feat: support fixed size list for array reverse#16423
Merged
comphead merged 3 commits intoJun 18, 2025
Merged
Conversation
jonathanc-n
reviewed
Jun 16, 2025
Contributor
jonathanc-n
left a comment
There was a problem hiding this comment.
This looks good to me, just a few pointers
Comment on lines
+196
to
+217
| let value_length = array.value_length(); | ||
|
|
||
| for row_index in 0..(array.len() as i32) { | ||
| // skip the null value | ||
| if array.is_null(row_index as usize) { | ||
| nulls.push(false); | ||
| mutable.extend(0, 0, 1); | ||
| continue; | ||
| } else { | ||
| nulls.push(true); | ||
| } | ||
|
|
||
| let start = row_index * value_length; | ||
| let end = (row_index + 1) * value_length; | ||
|
|
||
| let mut index = end - 1; | ||
|
|
||
| while index >= start { | ||
| mutable.extend(0, index as usize, index as usize + 1); | ||
| index -= 1; | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
This can be refactored, instead of converting to usize later we can convert this to usize first. rev function can also be used for the reverse logic
Suggested change
| let value_length = array.value_length(); | |
| for row_index in 0..(array.len() as i32) { | |
| // skip the null value | |
| if array.is_null(row_index as usize) { | |
| nulls.push(false); | |
| mutable.extend(0, 0, 1); | |
| continue; | |
| } else { | |
| nulls.push(true); | |
| } | |
| let start = row_index * value_length; | |
| let end = (row_index + 1) * value_length; | |
| let mut index = end - 1; | |
| while index >= start { | |
| mutable.extend(0, index as usize, index as usize + 1); | |
| index -= 1; | |
| } | |
| } | |
| let value_length = array.value_length() as usize; | |
| for row_index in 0..array.len() { | |
| // skip the null value | |
| if array.is_null(row_index) { | |
| if array.is_null(row_index) { | |
| nulls.push(false); | |
| mutable.extend(0, 0, 1); | |
| continue; | |
| } else { | |
| nulls.push(true); | |
| } | |
| let start = row_index * value_length; | |
| let end = start + value_length; | |
| for idx in (start..end).rev() { | |
| mutable.extend(0, idx, idx + 1); | |
| } | |
| } |
| select array_reverse(arrow_cast(make_array(1, 2, 3), 'FixedSizeList(3, Int64)')), array_reverse(arrow_cast(make_array(1), 'FixedSizeList(1, Int64)')); | ||
| ---- | ||
| [3, 2, 1] [1] | ||
|
|
Contributor
There was a problem hiding this comment.
Lets add a test for null values as well
13482f3 to
4aeb100
Compare
comphead
approved these changes
Jun 17, 2025
Contributor
comphead
left a comment
There was a problem hiding this comment.
lgtm thanks @chenkovsky and @jonathanc-n for the review
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
array_reverse doesn't support fixed size list now.
What changes are included in this PR?
support fixed size list for array_reverse
Are these changes tested?
UT
Are there any user-facing changes?
No